package com.demo2.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import sun.security.provider.Sun;

import java.util.concurrent.atomic.AtomicInteger;


@RestController
public class Provider2Controller {


    @RequestMapping("/provider/find")
    public String decrease() {
        System.out.println("2被请求了");
        return "Provider success2";
    }

     AtomicInteger atomicInteger = new AtomicInteger(1); //初始值1

    @GetMapping("/provider/list")
    public String deSentinel05() throws InterruptedException {
        int count = atomicInteger.getAndIncrement();//先取值，再递增
        if (count %2 == 0) {
            Thread.sleep(200);  //模拟耗时
        }
        return "test Sentinel 05";
    }


}
